import requests
import hashlib
import time
import base64
url = "https://www.python-spider.com/api/challenge1"

headers = {}

def encrypt():
    a = '9622'
    timestamp = str(int(time.time()))
    tokens = hashlib.md5(base64.b64encode((a+timestamp).encode('utf-8'))).hexdigest()
    headers['safe'] = tokens
    headers['timestamp'] = timestamp

answer = 0
for i in range(1,101):
    list = {
        "page": i
    }
    # 获取解密header
    encrypt()
    r = requests.post( url, headers=headers, data=list)
    data = r.json()['data']
    for item in data:
        answer += int(item['value'])

print(answer)